package com.tr.rentcar.controller.houtai.car;

import java.io.IOException;
import java.sql.SQLException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.tr.rentcar.model.bean.CarAttr;
import com.tr.rentcar.model.dao.CarAttrDao;
import com.tr.rentcar.model.dao.CarStyleDao;
@WebServlet("/carinsert")
public class CarinsertControllor extends HttpServlet {
	CarAttrDao CarAttrDao=new CarAttrDao();
	CarStyleDao CarStyleDao=new CarStyleDao();
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		
		String pid=req.getParameter("pid");
		Integer pId=Integer.parseInt(pid);
		if(pId==1){
			try {
		String name=req.getParameter("name");
		CarStyleDao.insert(name);
		resp.sendRedirect(req.getContextPath()+"/carattr");
			}catch (SQLException e) {
			e.printStackTrace();
		}
		}
		if(pId==2){
			String name=req.getParameter("name");
			String value=req.getParameter("value");
			resp.sendRedirect(req.getContextPath()+"/carattrval");
		}
		
		
	}
}
